package com.md.application.service.users;

import com.google.common.collect.Lists;
import com.md.api.authentication.InternalApi;
import com.md.domain.service.AuthenticationDomainService;
import com.md.model.request.IdListRequest;
import com.md.model.response.authentication.users.InternalUsersResponse;
import com.md.model.system.CommonResult;
import com.md.util.ObjectUtil;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 刘骄阳
 * 2023-12-27 16:53
 */
@Service
@RequiredArgsConstructor
public class InternalApplicationService implements InternalApi {
  private final AuthenticationDomainService authenticationDomainService;

  /**
   * 查询用户信息
   *
   * @param request 用户id列表
   * @return 操作结果
   */
  @Override
  public CommonResult<List<InternalUsersResponse>> selectUserListByIds(final IdListRequest request) {
    if (ObjectUtil.isEmpty(request.getIds())) {
      return CommonResult.success(Lists.newArrayList());
    }
    return CommonResult.success(authenticationDomainService.queryUserInfoByIds(request.getIds()));
  }
}
